<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>编辑商品参数</title>
	<#include "/common/vue_resource.ftl">
</head>
<body>
<div id="app" v-cloak>
	<div class="ui-form">
		<form class="layui-form" @submit.prevent="submitForm()" method="post">
			<div class="layui-form-item">
				<label class="layui-form-label">名称<span class="ui-request">*</span></label>
				<div class="layui-input-block">
					<input type="text" v-model="record.name" placeholder="请输入名称" class="layui-input"/>
				</div>
			</div>
			<#--<div class="layui-form-item">
				<label class="layui-form-label">商品类型<span class="ui-request">*</span></label>
				<div class="layui-input-block">
					<input type="text" v-model="record.productAttributeCategoryId" placeholder="请输入商品属性分类id" class="layui-input"/>
				</div>
			</div>-->
			<div class="layui-form-item">
				<label class="layui-form-label">录入方式</label>
				<div class="layui-input-block" style="padding-top:10px;min-height: 26px;">
					<label class="ui-form-label"><input type="radio" v-model="record.selectType" value="0"/> 手工录入</label>
					<label class="ui-form-label"><input type="radio" v-model="record.selectType" value="1"/> 单选</label>
					<label class="ui-form-label"><input type="radio" v-model="record.selectType" value="2"/> 多选</label>
				</div>
			</div>
			<#--<div class="layui-form-item">
				<label class="layui-form-label">录入方式</label>
				<div class="layui-input-block" style="padding-top:10px;min-height: 26px;">
					<label class="ui-form-label"><input type="radio" v-model="record.inputType" value="0"/> 手工录入</label>
					<label class="ui-form-label"><input type="radio" v-model="record.inputType" value="1"/> 从列表中选取</label>
				</div>
			</div>-->
			<div class="layui-form-item">
				<label class="layui-form-label">可选值列表</label>
				<div class="layui-input-block">
					<textarea v-model="record.inputList" class="layui-textarea"></textarea>
					<div class="layui-form-mid layui-word-aux">多个选项，以逗号隔开或者换行</div>
				</div>
			</div>
			<#--<div class="layui-form-item">
				<label class="layui-form-label">手动新增</label>
				<div class="layui-input-block" style="padding-top:10px;min-height: 26px;">
					<label class="ui-form-label"><input type="radio" v-model="record.handAddStatus" value="0"/> 不支持</label>
					<label class="ui-form-label"><input type="radio" v-model="record.handAddStatus" value="1"/> 支持</label>
				</div>
			</div>-->
			<div class="layui-form-item">
				<label class="layui-form-label">排序字段</label>
				<div class="layui-input-block">
					<input type="text" v-model="record.sort" placeholder="请输入排序字段" class="layui-input"/>
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="submit" value="保存" class="layui-btn" />
				</div>
			</div>
		</form>
	</div>
</div>
<script>
	var app = new Vue({
		el: '#app',
		data: {
			showTypes: false,
			record : {
				id:'${params.id!}',
				productAttributeCategoryId:'${params.categoryId!}',
				name:'',
				selectType:'0',
				inputType:'0',
				inputList:'',
				sort:'0',
				/*filterType:'',
				searchType:'',
				relatedStatus:'',*/
				handAddStatus:'0',
			},
		},
		mounted: function () {
			this.init();
			this.loadData();
		},
		methods: {
			init:function(){
				var that = this;
				/*laydate.render({elem: '#beginDate', type:'datetime', done:function (value) {
						that.record.beginDate = value;
					}});*/

			},
			loadData: function () {
				if (!'${params.id!}') {
					return;
				}
				var that = this;
				$.http.post('${params.contextPath}/web/pmsProductAttribute/query.json', {id: '${params.id!}'}).then(function (data) {
					if (!data.success) {
						$.message(data.message);
						return;
					}
					var item = data.data;
					for (var key in  that.record) {
						that.record[key] = item[key];
					}

					if (item.inputList) {
						that.record.inputList = item.inputList.replaceAll(",", "\n");
					}
				});
			},
			submitForm: function () {
				$.http.post('${params.contextPath}/web/pmsProductAttribute/<#if (params.id)??>modify<#else>save</#if>.json', this.record).then(function (data) {
					if (!data.success) {
						$.message(data.message);
						return;
					}
					var alt = layer.alert(data.message || "操作成功", function () {
						parent.app.loadData();
						parent.layer.closeAll();
						layer.close(alt);
					});
				});
			},
		}
	});
</script>
</body>

</html>
